package com.hntx.joymusic.sytRetrofity;

import com.google.gson.JsonObject;

import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.HeaderMap;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

interface SytApi {

    @GET("/ybly-hd/playLogTime.jsp")
    Observable<JsonObject> getPlayTime(@Query("tiem") String tiem,
                                       @Query("userid") String userid, @Query("mcode") String mcode);

    @POST("joymusic_cs_zjdx/userSongU")
    Observable<JsonObject> postCollect(@Query("o") String collect,
                                       @Query("e") String songId,
                                       @Query("u") String userid,
                                       @Query("p") String platform);

    //?o=delPlayerChecked&i=" + songId + "&u=" + userid + "&p=" + platform + "&s=HD"
    @POST("joymusic_cs_zjdx/otherOperaU")
    Observable<JsonObject> postDel(@Query("o") String del,
                                   @Query("i") String songId,
                                   @Query("u") String userid,
                                   @Query("p") String platform,
                                   @Query("s") String hd);

    //2021.06.03
    @Streaming
    @GET
    Observable<ResponseBody> download(@Url String url);

    //2021.06.03
    @GET("joymusic_cs_zjdx/apk/apkInter.jsp")
    Observable<Integer> getNewVersionCode();


    @Multipart
    @POST("joymusic_cs_zjdx/video/")
    Observable<String> upFile(@Part MultipartBody.Part part);

    @POST("api/listCorp.action")
    Observable<JsonObject> queryYunList(@Header("AccessToken") String accessToken,
                                        @Header("Signature") String signature,
                                        @Header("Date") String date,
                                        @Query("appKey") String appKey);

    @GET("api/getCorpInfo.action")
    Observable<String> getCorpInfo(@Header("AccessToken") String accessToken,
                                   @Header("Signature") String signature,
                                   @Header("Date") String date,
                                   @Query("corpId") String corpId);

    @GET("api/listCorpUser.action")
    Observable<String> getCorpMemberList(@Header("AccessToken") String accessToken,
                                         @Header("Signature") String signature,
                                         @Header("Date") String date,
                                         @Query("corpId") String corpId);

    @GET("api/listCompanyFiles.action")
    Observable<String> getSpecifiedFiles(@Header("AccessToken") String accessToken,
                                         @Header("Signature") String signature,
                                         @Header("Date") String date, @QueryMap Map<String, Object> map);

    @POST("api/createCompanyFolder.action")
    Observable<JsonObject> createCorpFiles(@Header("AccessToken") String accessToken,
                                           @Header("Signature") String signature,
                                           @Header("Date") String date,
                                           @Query("appKey") String appKey,
                                           @Query("corpId") String corpId,
                                           @Query("parentId") String parentId,
                                           @Query("fileName") String fileName);

    @POST("api/getCorpPutUploadURL.action")
    Observable<JsonObject> getCorpPutUploadURL(@Header("AccessToken") String accessToken,
                                               @Header("Signature") String signature,
                                               @Header("Date") String date,
                                               @Query("appKey") String appKey,
                                               @Query("corpId") String corpId);

    @POST("api/createCompanyFolder.action")
    Observable<String> piCreateFiles(@Header("AccessToken") String accessToken,
                                     @Header("Signature") String signature,
                                     @Header("Date") String date, @Body RequestBody body);

    @GET("api/getCompanyFileInfo.action")
    Observable<String> cxSingleCorpInfo(@Header("AccessToken") String accessToken,
                                        @Header("Signature") String signature,
                                        @Header("Date") String date,
                                        @Query("corpId") String corpId,
                                        @Query("fileId") String fileId);

    @GET("api/getCompanyFileDownload.action")
    Observable<String> cxSingleCorpFileInfo(@Header("AccessToken") String accessToken,
                                            @Header("Signature") String signature,
                                            @Header("Date") String date,
                                            @Query("corpId") String corpId,
                                            @Query("fileId") String fileId);

    @POST("api/removeCompanyFile.action")
    Observable<String> deleteFile(@Header("AccessToken") String accessToken,
                                  @Header("Signature") String signature,
                                  @Header("Date") String date, @Query("corpId") String corpId,
                                  @Query("fileIdList") String fileIdList);

    @POST("api/renameCompanyFile.action")
    Observable<String> renameFile(@Header("AccessToken") String accessToken,
                                  @Header("Signature") String signature,
                                  @Header("Date") String date, @Query("corpId") String corpId,
                                  @Query("fileId") String fileId, @Query("fileName") String fileName);

    @POST("api/copyCompanyFile.action")
    Observable<String> copyFile(@Header("AccessToken") String accessToken,
                                @Header("Signature") String signature,
                                @Header("Date") String date, @Body RequestBody body);

    @GET("api/createCoshare.action")
    Observable<String> createCoshare(@Header("AccessToken") String accessToken,
                                     @Header("Signature") String signature,
                                     @Header("Date") String date,
                                     @Query("corpId") String corpId,
                                     @Query("coshareName") String coshareName);

    @POST("api/listJoinCorpCoshare.action")
    Observable<String> listJoinCorpCoshare(@Header("AccessToken") String accessToken,
                                           @Header("Signature") String signature,
                                           @Header("Date") String date, @Body RequestBody body);

    @POST("api/listCoshareFile.action")
    Observable<String> listCoshareFile(@Header("AccessToken") String accessToken,
                                       @Header("Signature") String signature,
                                       @Header("Date") String date, @Body RequestBody body);

    @POST("api/createCoshareFolders.action")
    Observable<String> createCoshareFolders(@Header("AccessToken") String accessToken,
                                            @Header("Signature") String signature,
                                            @Header("Date") String date, @Body RequestBody body);

    @GET("api/getCoshareInfo.action")
    Observable<String> getCoshareFileInfo(@Header("AccessToken") String accessToken,
                                          @Header("Signature") String signature,
                                          @Header("Date") String date, @Query("corpId") String corpId,
                                          @Query("coshareId") String coshareId);

    @GET("api/getCoshareFileInfo.action")
    Observable<String> getsingleCoshareFileInfo(@Header("AccessToken") String accessToken,
                                                @Header("Signature") String signature,
                                                @Header("Date") String date, @Query("corpId") String corpId,
                                                @Query("coshareId") String coshareId,
                                                @Query("fileId") String fileId);

    @GET("api/renamecoshare.action")
    Observable<String> renamecoshare(@Header("AccessToken") String accessToken,
                                     @Header("Signature") String signature,
                                     @Header("Date") String date, @Query("corpId") String corpId,
                                     @Query("coshareId") String coshareId,
                                     @Query("coshareName") String coshareName);

    @GET("api/createCoshareFile.action")
    Observable<String> createCoshareFile(@Header("AccessToken") String accessToken,
                                         @Header("Signature") String signature,
                                         @Header("Date") String date, @Query("corpId") String corpId,
                                         @Query("coshareId") String coshareId,
                                         @Query("parentId") String parentId,
                                         @Query("fileName") String fileName);

    @GET("api/renameCoshareFile.action")
    Observable<String> renameCoshareFile(@Header("AccessToken") String accessToken,
                                         @Header("Signature") String signature,
                                         @Header("Date") String date, @Query("corpId") String corpId,
                                         @Query("coshareId") String coshareId,
                                         @Query("fileId") String fileId,
                                         @Query("newFileName") String newFileName);


    @GET("api/putShareFile2Recycle.action")
    Observable<String> putShareFile2Recycle(@Header("AccessToken") String accessToken,
                                            @Header("Signature") String signature,
                                            @Header("Date") String date, @Query("corpId") String corpId,
                                            @Query("coshareId") String coshareId,
                                            @Query("fileIdList") String fileIdList);


    @POST
    Observable<JsonObject> putCorpFile(@Url String url, @Body RequestBody body, @HeaderMap Map<String, String> map);


    @POST("api/createCorpUploadFile.action")
    Observable<String> createCorpUploadFile(@HeaderMap Map<String, String> headerMap, @Body RequestBody body);

    @GET("api/getCorpUploadFileStatus.action")
    Observable<String> getCorpUploadFileStatus(@HeaderMap Map<String, String> headerMap,
                                               @Query("uploadFileId") Long uploadFileId,
                                               @Query("corpId") Long corpId,
                                               @Query("isLog") String isLog);

    @PUT("/corp/uploadCorpFile.action")
    Observable<String> uploadCorpFile(@HeaderMap Map<String, String> map);

    @POST("/corp/commitCorpFile.action")
    Observable<String> commitCorpFile(@HeaderMap Map<String, String> headerMap, @Body RequestBody body);

    @POST("api/getFileDownloadUrl.action")
    Observable<String> getFileDownloadUrl(@HeaderMap Map<String, String> headerMap, @Body RequestBody body);

    @POST("api/batchGetFileDownloadUrl.action")
    Observable<String> batchGetFileDownloadUrl(@HeaderMap Map<String, String> headerMap, @Body RequestBody body);

    @GET("api/getDirectUploadUrls.action")
    Observable<String> getDirectUploadUrls(@HeaderMap Map<String, String> headerMap, @Query("corpId") Long corpId,
                                           @Query("day") Integer day, @Query("urlTimes") Integer urlTimes,
                                           @Query("clientIp") String clientIp);

    @PUT
    Observable<String> realUploadFile(@HeaderMap Map<String, Object> headerMap, @Query("date") String date,
                                      @Query("authorization") String authorization);

    @GET("api/createFile4Direct.action")
    Observable<String> createFile4Direct(@HeaderMap Map<String, String> headerMap,
                                         @Query("corpId") Long corpId, @Query("parentId") Long parentId,
                                         @Query("fileName") String fileName, @Query("size") Long size,
                                         @Query("md5") String md5, @Query("objectId") String objectId,
                                         @Query("ETag") String ETag, @Query("ContentLength") Long ContentLength);

    @GET("open/oauth2/accessToken.action")
    Observable<JsonObject> getYunToken(@Query("appKey") String appKey,
                                       @Query("appSignature") String appSignature,
                                       @Query("grantType") String grantType,
                                       @Query("deviceAccount") String deviceAccount,
                                       @Query("timestamp") Long timestamp);

    //yunAppkey, timestamp, version, paras,sign
    @GET("openAccount/createCorp.action")
    Observable<JsonObject> createAccount(@Query("appKey") String appKey,
                                         @Query("timeStamp") String timeStamp,
                                         @Query("format") String format,
                                         @Query("version") String version,
                                         @Query("paras") String paras,
                                         @Query("sign") String sign);

    @GET("joymusic_cs_zjdx/androidWeChat")
    Observable<String> getQRcode(@Query("userid") String userid,@Query("height") int height);
}
